<ui:composition template="/template/LayoutPadrao.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsf/composite/componentes">

	<ui:define name="titulo">#{msg.entry}</ui:define>
	<ui:define name="conteudo">
		<h:outputStylesheet name="consulta-lancamentos.css" library="css" />

		<h1>#{msg.entry}</h1>

		<h:form id="frm">

			<h:commandButton value="#{msg.newEntry}"
				action="NovoLancamento?faces-redirect=true"
				rendered="#{request.isUserInRole('cadastro')}" />

			<h:messages showDetail="false" showSummary="true"
				styleClass="form-messages" errorClass="error" infoClass="info" />
			<h:dataTable var="lancamento"
				value="#{consultaLancamentoBean.lancamentos}" width="100%"
				styleClass="grid" headerClass="cabecalho"
				rowClasses="cor-sim, cor-nao"
				columnClasses="tipo, pessoa, descricao, valor, vencimento, pagamento, situacao, acoes">
				<h:column>
					<h:graphicImage value="/imagens/despesa.png"
						rendered="#{lancamento.tipo eq 'DESPESA'}" />
					<h:graphicImage value="/imagens/receita.png"
						rendered="#{lancamento.tipo eq 'RECEITA'}" />
				</h:column>
				<h:column>
					<f:facet name="header">
					#{msg.person}
				</f:facet>
					<h:link outcome="NovaPessoa">
						<h:outputText value="#{lancamento.pessoa.nome}" />
						<f:param name="codigo" value="#{lancamento.pessoa.codigo}" />
					</h:link>
				</h:column>

				<h:column>
					<f:facet name="header">
					#{msg.description}
				</f:facet>
					<h:outputText value="#{lancamento.descricao}" />
				</h:column>

				<h:column>
					<f:facet name="header">
					#{msg.value}
				</f:facet>
					<c:outputCurrency value="#{lancamento.valor}"
						styleClass="#{lancamento.tipo.toString().toLowerCase()}" />
				</h:column>

				<h:column>
					<f:facet name="header">
					#{msg.due_date}
				</f:facet>
					<c:outputDate value="#{lancamento.dataVencimento}" />
				</h:column>

				<h:column>
					<f:facet name="header">
					#{msg.payment}
				</f:facet>
					<c:outputDate value="#{lancamento.dataPagamento}" />
				</h:column>

				<h:column>
					<f:facet name="header">
					#{msg.situation}
				</f:facet>
					<h:outputText value="#{msg.payed}" rendered="#{lancamento.pago}" />
					<h:outputText value="#{msg.pendent}" rendered="#{not lancamento.pago}" />
				</h:column>

				<h:column rendered="#{request.isUserInRole('cadastro')}">
					<h:link outcome="NovoLancamento">
						<h:graphicImage value="/imagens/editar.png" />
						<f:param name="codigo" value="#{lancamento.codigo}" />
					</h:link>
					<h:commandLink action="#{consultaLancamentoBean.excluir}">
						<h:graphicImage value="/imagens/excluir.png" />
						<f:setPropertyActionListener
							target="#{consultaLancamentoBean.lancamentoSelecionado}"
							value="#{lancamento}" />
						<f:ajax render="@form" />
					</h:commandLink>
				</h:column>
			</h:dataTable>
		</h:form>


	</ui:define>

</ui:composition>



